﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace DynamicDnsChanger.Extensions.Requester
{
    [Export(typeof(IRequester))]
    public class Requester: IPlugin, IRequester
    {

        public string Name
        {
            get { return "Requester"; }
        }

        public event EventHandler<InfoStatus> StatusChange;

        public string GetString(string requestUri)
        {
            
            
             using (var _client = new HttpClient())
            {

                var header = new string[] { "DynamicDnsChanger","v1.0" };                 
                //_client.DefaultRequestHeaders.Add("User-Agent", @"DynamicDnsChanger/ v1.0 perigo@gmail.com");
                _client.DefaultRequestHeaders.Add("User-Agent", header.ToArray());
                 var result = _client.GetStringAsync(requestUri);
                return result.Result;
             }
        }

        public string PostAsync(string requestUri, IDictionary<string, string> content)
        {
            throw new NotImplementedException();
        }
    }
}
